package main

import (
	"context"
	"fmt"
	"google.golang.org/grpc"
)

func LogInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) {
	// 前置逻辑
	fmt.Println("log start")
	// 调用业务逻辑
	resp, err = handler(ctx, req)
	// 后置逻辑
	fmt.Println("log end")
	return // Go 语言支持命名返回值
}
func ErrInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) {
	fmt.Println("err start")
	resp, err = handler(ctx, req)
	fmt.Println("err end")
	return
}
